<%@page import="net.zretc.entitys.Pet"%>
<%@page import="java.util.List"%>
<%@page import="net.zretc.entitys.Users"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心</title>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/center.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery.min.js"></script>
    <!-- <script src="js/center.js"></script> -->
</head>

<body style="background-color: #f6f3f3;">
<c:if test="${users!=null}">
    <div>
        <!-- 头部 -->
        <div class="w clearfix">
            <div class="fl logo">
                <img src="img/logo.png" alt="">
            </div>
            <div class="fl serch clearfix">
                <form action="show.do" method="post">
                    <input type="text" placeholder="请输入关键字" class="fl" name="name">
                    <button class="fr">搜索</button>
                </form>
            </div>
            <div class=" user">
                <span><a href="show.do">首页</a></span>
            </div>

        </div>
        <div class="bd w clearfix">
            <div class="bd_lf ">
                <ul>
                    <li class="current">个人资料</li>
                    <li>密码设置</li>
                    <li>我的订单</li>
                </ul>
            </div>
            <div class="bd_rt">
                <div style="width: 800px;margin: auto;" class="bd_bd wd">
                    <form action="userupd.do" method="post" onsubmit="return checkInput(this)">
                        <h1>个人信息</h1>
                        <input type="hidden" name="id" value="${users.id}"  >
                        <input type="hidden" name="password" value="${users.pwd}" >
                        <div class="form-group">
                            <label >用户名</label>
                            <input type="text" class="form-control" name="username" id="username" placeholder="name" value="${users.username}">
                        </div>
                        <div class="form-group">
                            <label >收货人</label>
                            <input type="text" class="form-control" name="realname"
                                placeholder="realname" value="${users.realname }">
                        </div>
                        <div class="form-group">
                            <label >收货手机号</label>
                            <input type="number" class="form-control" name="phone"
                               value="${users.phone }" placeholder="phone">
                        </div>
                        
                        <div class="form-group">
                            <label>收货地址</label>
                            <input type="text" class="form-control" placeholder="address" name="address" value="${users.address }">
                        </div>
                        
                        <button type="submit" class="btn btn-default" style="margin:auto;">提交</button>
                    </form>
                </div>
                <!-- 修改密码 -->
                <div style="width: 800px;margin: auto;" class="bd_bd1 wd">
                     <form action="userupd.do" method="post" onsubmit="return checkInput(this)">
                        <h1>修改密码</h1>
                        <div class="form-group">
                            <label for="exampleInputPassword1" >请输入要修改成的密码</label>
                           	<input type="password" class="form-control" id="hhhmima" placeholder="password" value="${users.pwd}">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPassword1">确认密码 </label>
                            <input type="password" class="form-control"   id="hhhmima1" name="password" value="${users.pwd}"
                                placeholder="Password">
                        </div>
                        <button type="submit" class="btn btn-default" style="margin:auto;">提交</button>
                        <input type="hidden" name="id" value="${users.id}" >
                        <input type="hidden" name="username" value="${users.username}">
                        <input type="hidden" name="phone" value="${users.phone }">
                        <input type="hidden"  name="address" value="${users.address }">
                        <input type="hidden" name="realname" value="${users.realname }">
                    </form>
                </div>
				<!-- 订单管理 -->	
				<c:if test="${users!=null}">
					<%
						Users a=(Users)session.getAttribute("users");
						String name=a.getUsername()+"shop";
						Object b=application.getAttribute(name);
						if(b==null){
							System.out.print("无");
						}else{
							List<Pet> list=(List<Pet>)b;
							request.setAttribute("piapialist1", list);
						}
					%>
				</c:if>
                <div style="width: 800px;margin: auto;" class="bd_bd2 wd">
                        <h1>我的订单</h1>
                        <c:if test="${piapialist1!=null}">
	                        <table class="table table-hover">
					<!-- On rows -->
					
					<tr>
						<td>id</td>
						<td>商品</td>
						<td>单价</td>
						<td>是否出货</td>
						<td></td>
					</tr>
					
					<c:forEach items="${piapialist1}" var="pet1" varStatus="status">
						<tr>
							<td>${status.index+1 }</td>
							<td>${pet1.title}</td>
							<td>${pet1.price}元</td>
							<td>${pet1.status}</td>
							<td><a href="petsale.do?id=${pet1.id }">退货</a></td>
						</tr>
					</c:forEach>
					<!-- <h1>没有商品</h1> -->
				</table>
	                     </c:if>   

					
                </div>
            </div>

        </div>
    </div>
    <script>
        $(function () {

            $(".bd_lf li").click(function () {

                $(".wd").eq($(this).index()).css("display", "block").siblings().css("display", "none")
                $(this).addClass("current").siblings().removeClass();
            });

        })
         $(".btn").click(function () {
                if ($("#hhhmima").val() != $("#hhhmima1").val()) {
                    alert("密码不一致！")
					return false; 
                }
				if ($("#hhhmima").val().length==0) {
	                    alert("密码不能为空！")
						return false; 
	                }
				if ($("#username").val().length==0) {
					                    alert("用户名不能为空！")
										return false; 
					                }
            })
		
    </script>
   </c:if>
   <c:if test="${users==null}">
   		<script type="text/javascript">
   		window.location.href="register.jsp";
   		</script>
   </c:if>
</body>

</html>